<extend name="./public/frame.html"/>
<block name="content">
    <form class="layui-form layui-form-pane1" method="post" enctype="multipart/form-data">
    <table class="layui-table">
        <tr>
            <td colspan="4">申请开票信息</td>
        </tr>
        <tr>
            <td style="text-align: center;width: 12%">手机号</td>
            <td style="width: 20%"><?php echo $info['user_phone'];?></td>
            <td style="text-align: center;width: 12%">申请时间</td>
            <td><?php echo date("Y-m-d H:i:s",$info['add_time']);?></td>
        </tr>
        <tr>
            <td style="text-align: center;">发票流水号</td>
            <td><?php echo $info['invoice_sn'];?></td>
            <td style="text-align: center;">发票类型</td>
            <td><?php if($info['invoice_type'] == 1):?>电子发票<?php else:?>纸质发票<?php endif;?></td>
        </tr>
        <tr>
            <td style="text-align: center;">发票内容</td>
            <td><?php echo $info['content'];?></td>
            <td style="text-align: center;">发票金额</td>
            <td><?php echo $info['money']/100;?></td>
        </tr>
        <tr>
            <td style="text-align: center;">抬头类型</td>
            <td><?php if($info['title_type'] == 1):?>公司抬头<?php else:?>个人抬头<?php endif;?></td>
            <td style="text-align: center;">发票抬头</td>
            <td><?php echo $info['title'];?></td>
        </tr>
        <tr>
            <td style="text-align: center;">税号</td>
            <td><?php echo $info['taxpayerId'];?></td>
            <td style="text-align: center;">收件人（电话/地址）</td>
            <td>
                <?php if($info['invoice_type'] == 1):?>
                <?php echo $info['address_phone'];?>
                <?php else:?>
                <?php echo $info['addressee'];?> - <?php echo $info['addressee_phone'];?> - <?php echo $info['addressee_address'];?>
                <?php endif;?>
            </td>
        </tr>
        <tr>
            <td style="text-align: center;">开户行和账号</td>
            <td>
                <?php if($info['invoice_type'] == 1):?>
                <?php echo $info['bank_account'];?>
                <?php else:?>
                <?php echo $info['bank'];?> - <?php echo $info['account'];?>
                <?php endif;?>
            </td>
            <td style="text-align: center;">备注说明</td>
            <td><?php echo $info['remark'];?></td>
        </tr>
        <tr>
            <td style="text-align: center;">电子邮箱</td>
            <td><?php echo $info['email'];?></td>
            <td style="text-align: center;">发票状态（处理时间）</td>
            <td>
                <?php if($info['status'] == 2):?>
                <span style="color: green">已开票</span>
                <?php echo date("Y-m-d H:i:s",$info['invoice_time']);?>
                <?php elseif($info['status'] == 1):?>
                <span style="color: red">待处理</span>
                <?php endif;?>
            </td>
        </tr>
        <?php if($info['status'] != 2):?>
        <tr>
            <td colspan="4">
                <input type="hidden" value="<?php echo $info['invoice_common_id'];?>" name="invoice_common_id">
                <button class="layui-btn" lay-submit lay-filter="*">确认开票</button>
            </td>
        </tr>
        <?php endif;?>
        <?php if(!empty($express_info)):?>
        <tr>
            <td colspan="4">物流信息</td>
        </tr>
        <tr>
            <td style="text-align: center;">快递流水号</td>
            <td><?php echo $express_info['express_number'];?></td>
            <td style="text-align: center;">快递公司名称</td>
            <td><?php echo $express_info['express_name'];?></td>
        </tr>
        <tr>
            <td style="text-align: center;">快递单号</td>
            <td><?php echo $express_info['express_sn'];?></td>
            <td style="text-align: center;">发件人</td>
            <td><?php echo $express_info['user_name'];?></td>
        </tr>
        <tr>
            <td style="text-align: center;">寄送物品名称</td>
            <td><?php echo $express_info['send_goods_name'];?></td>
            <td style="text-align: center;">寄运物品的数量</td>
            <td><?php echo $express_info['goods_shipped_number'];?></td>
        </tr>
        <tr>
            <td style="text-align: center;">快递下单时间</td>
            <td><?php echo $express_info['express_at'];?></td>
            <td style="text-align: center;">备注</td>
            <td><?php echo $express_info['remark'];?></td>
        </tr>
        <?php endif;?>
        <tr>
            <td colspan="4">开票相关行程信息</td>
        </tr>
        <tr>
            <td colspan="4">
                <table class="layui-table">
                    <tr>
                        <td style="text-align: center;">订单ID</td>
                        <td style="text-align: center;">订单号</td>
                        <td style="text-align: center;">发票类型</td>
                        <td style="text-align: center;">行程费用</td>
                    </tr>
                    <?php foreach($invoiceList as $value):?>
                    <tr>
                        <td style="text-align: center;"><?php echo $value['order_common_id'];?></td>
                        <td style="text-align: center;"><?php echo $value['order_sn'];?></td>
                        <td style="text-align: center;"><?php if($value['invoice_type'] == 1):?>城内网约车<?php else:?>城际专车<?php endif;?></td>
                        <td style="text-align: center;"><?php echo $value['money']/100;?></td>
                    </tr>
                    <?php endforeach;?>
                </table>
            </td>
        </tr>
    </table>
    </form>
    <script>
        layui.use(['form'], function () {
            var form = layui.form;
            form.on('submit(*)', function(data){
                $.ajax({
                    url:'{:url("/admin/Invoice/is_open")}',
                    async:true,
                    dataType:'json',
                    type:'POST',
                    data: $(data.form).serialize(),
                    success:function(res){
                        if(res.code==1){
                            layer.alert(res.msg, {icon: 6},function () {
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                                window.parent.location.reload()
                            });
                        }else{
                            layer.msg(res.msg,{icon: 5});
                        }
                    }
                });
                return false;
            });
        });
    </script>
</block>